@extends('public.home_base')
@section('title', '找回密码')

@section('content')
    <link rel="stylesheet" href="/static/css/index-style.css">


    <section class="center_container">
        <section class="login_container" style="height:560px;">
            <div class="banner">
                <p>
                    效率成就品牌
                    &emsp;
                    诚信铸就未来
                </p>
            </div>
            <div class="content">
                <form id="reg_form" action="zhaohuipw" method="post">
                    {{csrf_field()}}
                    <div class="box">
                        <div class="inner_title">
                            <span class="f20 text_orange">忘记密码</span>
                        </div>
                        <ul class="reg">
                            <li>
                                <span class="cl"><i class="text_red">*</i>邮箱：</span>
                                <div>
                                    <input type="text" name="email" placeholder="请输入邮箱">
                                </div>
                            </li>
                            <li>
                                <span class="cl"><i class="text_red">*</i>图形验证：</span>
                                <div>
                                    <input type="text" name="captcha" placeholder="请输入验证码" id="captchaInput">
                                    <img title="点击刷新" onclick="updateCaptcha()" id="captchaImg" class="jf-login-captcha" src="{{captcha_src()}}">
                                </div>
                            </li>
{{--                            <li>--}}
{{--                                <span class="cl"><i class="text_red">*</i>手机验证：</span>--}}
{{--                                <div>--}}
{{--                                    <input type="text" name="authCode" placeholder="请输入手机验证码">--}}
{{--                                    <input type="button" value="发送验证码" id="sms_send" class="btn btn_primary">--}}
{{--                                </div>--}}
{{--                            </li>--}}
{{--                            <li>--}}
{{--                                <span class="cl"><i class="text_red">*</i>密码：</span>--}}
{{--                                <div>--}}
{{--                                    <input type="password" name="password" placeholder="请输入密码">--}}
{{--                                </div>--}}
{{--                            </li>--}}
                            <li>
                                <span class="cl">&nbsp;</span>
                                <div>
                                    <button type="submit" class="btn btn_primary btn_submit">提交</button>
                                    <p class="text_center mt10">已经有账户？<a href="login">立即登录</a></p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
        </section>
    </section>
@endsection
@section('script')
    <script>
        function updateCaptcha() {
            var img = '{{captcha_src()}}';
            var timestamp = (new Date()).valueOf();
            $("#captchaImg").attr("src", img + '&t='+ timestamp);
        }


        $(function () {
            $("#reg_form").validate({
                rules: {
                    email: {
                        required: true,
                        email: true,
                    },
                    password: {
                        required: true,
                        minlength:6,

                    },
                    password2: {
                        required: true,
                       minlength:6,
                    },
                    captcha: {
                        required: true,
                        rangelength:[4,4]
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $('.btn_submit').attr('disabled', 'disabled');
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "",
                        success: function (data) {
                            if (data.msg === 'success') {
                                // layer.msg('发送成功!  请确认您的邮箱', {icon: 1, time: 2500}, function () {
                                //     // parent.window.location = parent.window.location;
                                //     //parent.layer.close(index);
                                //     window.location='login';
                                // });
                                layer.alert('发送成功!  请确认您的邮箱', {icon: 6},function(index){
                                    window.location='login';
                                    layer.close(index);
                                });
                            } else {
                                layer.msg(data.data.error, {icon: 2, time: 1000,});
                                updateCaptcha();
                                setTimeout(function () {
                                    $('.btn_submit').removeAttr('disabled');
                                }, 2000);
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg(XmlHttpRequest.responseJSON.data, {icon: 2, time: 1000}, function () {
                                updateCaptcha();
                                $('.btn_submit').removeAttr('disabled');
                            });
                        }
                    });
                }
            });
        });
    </script>
@endsection
@section('script')
    <script>
        function updateCaptcha() {
            var img = '{{captcha_src()}}';
            var timestamp = (new Date()).valueOf();
            $("#captchaImg").attr("src", img + '&t='+ timestamp);
        }


        $(function () {
            $("#reg_form").validate({
                rules: {
                    email: {
                        required: true,
                        email: true,
                    },
                    password: {
                        required: true,
                        minlength:6,

                    },
                    password2: {
                        required: true,
                        minlength:6,
                    },
                    captcha: {
                        required: true,
                        rangelength:[4,4]
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        type: 'post',
                        url: "",
                        success: function (data) {
                            if (data.msg === 'success') {
                                layer.msg('成功!', {icon: 1, time: 1000}, function () {
                                    // parent.window.location = parent.window.location;
                                    //parent.layer.close(index);
                                    window.location='/';
                                })
                            } else {
                                layer.msg(data.data.error, {icon: 2, time: 1000,});
                                updateCaptcha();
                            }
                        },
                        error: function (XmlHttpRequest, textStatus, errorThrown) {
                            layer.msg(XmlHttpRequest.responseJSON.data, {icon: 2, time: 1000}, function () {
                                updateCaptcha();
                                //parent.layer.close(index);
                                //window.location='/';
                            });
                        }
                    });
                }
            });
        });
    </script>
@endsection
